package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.feign.search.SearchFeignClient;
import com.atguigu.gmall.search.vo.SearchParamVo;
import com.atguigu.gmall.search.vo.SearchRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @ClassName: SearchController
 * @Author: WDD
 * @CreateTime: 2023-01-29  14:29
 * @Description:  检索服务
 */
@Controller
public class SearchController {

    @Autowired
    SearchFeignClient searchFeignClient;

    @GetMapping("/list.html")
    public String search(SearchParamVo param, Model model){
        SearchRespVo data = searchFeignClient.search(param).getData();
        //检索参数
        model.addAttribute("searchParam",data.getSearchParamVo());

        //品牌面包屑
        model.addAttribute("trademarkParam",data.getTrademarkParam());

        //平台属性面包屑
        model.addAttribute("propsParamList",data.getPropsParamList());

        //品牌列表
        model.addAttribute("trademarkList",data.getTrademarkList());

        //属性列表
        model.addAttribute("attrsList",data.getAttrsList());

        //URL参数
        model.addAttribute("urlParam",data.getUrlParam());

        //排序信息
        model.addAttribute("orderMap",data.getOrderMap());

        //商品列表
        model.addAttribute("goodsList",data.getGoodsList());

        //页码
        model.addAttribute("pageNo",data.getPageNo());

        //总页数
        model.addAttribute("totalPages",data.getTotalPages());

        return "list/index";
    }

}
